package keeto.com.vn.bms.network.task;

import java.io.IOException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.request.SendCommentRequest;
import keeto.com.vn.bms.network.response.SendCommentResponse;
import keeto.com.vn.bms.utils.BMSListener;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

public class TaskSendComment extends AbstractTask{
	String Schedule_id;
	String Content;
	String title;
	String Comment_date;
	String AuthKey;
	public TaskSendComment(BMSListener listener, IBMSCore core,
			String schedule_id, String content, String title,
			String comment_date, String authKey) {
		super(listener, core);
		Schedule_id = schedule_id;
		Content = content;
		this.title = title;
		Comment_date = comment_date;
		AuthKey = authKey;
	}
	@Override
	public void run() throws ClientProtocolException, JSONException, IOException {
		SendCommentRequest request = new SendCommentRequest();
		request.setAuthKey(AuthKey);
		request.setComment_date(Comment_date);
		request.setContent(Content);
		request.setContent(Content);
		request.setSchedule_id(Schedule_id);
		request.setTitle(title);
		SendCommentResponse reponse = protocol.sentComment(request);
		for (BMSListener mListener : listener){
			mListener.finishSentComment(reponse.getReturnCode(),reponse.getResultMsg());
		}
	}
	@Override
	public void timeoutCallback() {
		for (BMSListener mListener : listener){
			mListener.finishSentComment(protocol.STATUS_CODE_GENERIC_FAIL_CONECTTION,"");
		}
	}
	
}
